const express = require('express')
const router = express.Router()

const { getSceneryCount, getSceneryList, searchScenery, toggleHotScenery, deleteScenery, publishSceneryData } = require('../../controller/apis/SceneryController')
const { createUploadMiddleware } = require('../../middleware/UploadImageMiddleware')

// 导入JWT拦截中间件
const checkTokenMiddleware = require('../../middleware/checkTokenMiddleware')
// 导入分页中间件
const paginationMiddleware = require('../../middleware/paginationMiddleware');

// 获取景点总数
router.get('/scenery/count', checkTokenMiddleware, getSceneryCount)

// 获取景点列表信息
router.get('/scenery/list', paginationMiddleware, checkTokenMiddleware, getSceneryList)

// 景点列表搜索功能
router.get('/scenery/search', checkTokenMiddleware, searchScenery)

// 景点热门状态切换
router.patch('/scenery/hot/toggle/:id', checkTokenMiddleware, toggleHotScenery)

// 删除景点
router.delete('/scenery/del/:id', checkTokenMiddleware, deleteScenery)

// 上传景点图片
const uploadPostImages = createUploadMiddleware('Scenery')
router.post('/scenery/upload', checkTokenMiddleware, uploadPostImages)

// 发布景点
router.post('/scenery/publish', checkTokenMiddleware, publishSceneryData)

module.exports = router